package com.heima.utils.thread;

import com.heima.model.wemedia.pojos.WmUser;

/**
 * 这个工具类用到threadlocal来在
 * 同一个线程中存储共享某一数据
 *
 * @author 10161
 */
public class WmThreadLocalUtil {
    private static ThreadLocal<WmUser> THREADLOCAL = new ThreadLocal<>();

    //1.存入数据
    public static void setUser(WmUser user) {
        THREADLOCAL.set(user);
    }

    //2.获取数据
    public static WmUser getUser() {
        return THREADLOCAL.get();
    }

    //3.清理数据
    public static void clear() {
        THREADLOCAL.remove();
    }

}
